package com.hdd.art.biz.show.controller;

import com.hdd.art.biz.show.dto.ArtShowDo;
import com.hdd.art.biz.show.dto.OpenScreensDo;
import com.hdd.art.biz.show.dto.OpenScreensInfoDo;
import com.hdd.art.biz.show.entity.OpenScreen;
import com.hdd.art.biz.show.service.OpenScreenService;
import com.hdd.art.dto.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/art-show/screen")
@Api(value = "美术馆-开屏",tags = {"美术馆-开屏"})
public class ArtOpenScreenController {

    @Autowired
    private OpenScreenService openScreenService;



    @PostMapping("/setDefaultOpenScreen")
    @ApiOperation(value = "设置默认开屏画" ,notes = "")
    public AppResponse setDefaultOpenScreen(@Valid @RequestBody OpenScreensDo screensDo ){
        AppResponse response = new AppResponse();
        openScreenService.setDefaultOpenScreen(screensDo.getId());
        return response;
    }



    @PostMapping("/findDefaultOpenScreenByArtId")
    @ApiOperation(value = "开屏画默认" ,notes = "")
    public AppResponse findDefaultOpenScreenByArtId(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        response.setItem(openScreenService.defaultOpenScreenByArtId(artShowDo.getArtId()));
        return response;
    }


    @PostMapping("/findOpenScreensByArtId")
    @ApiOperation(value = "开屏画列表" ,notes = "")
    public AppResponse find(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        response.setItems(openScreenService.findOpenScreenByArtId(artShowDo.getArtId()));
        return response;
    }


    @PostMapping("/addOpenScreens")
    @ApiOperation(value = "开屏画添加" ,notes = "")
    public AppResponse addOpenScreens(@Valid @RequestBody OpenScreensInfoDo screensInfoDo ){
        AppResponse response = new AppResponse();
        OpenScreen openScreen = new OpenScreen();
        BeanUtils.copyProperties(screensInfoDo,openScreen);
        openScreenService.insert(openScreen);
        return response;
    }


    @PostMapping("/delOpenScreens")
    @ApiOperation(value = "开屏画删除" ,notes = "")
    public AppResponse delOpenScreens(@Valid @RequestBody OpenScreensDo openScreensDo ){
        AppResponse response = new AppResponse();
        openScreenService.delete(openScreensDo.getId());
        return response;
    }



}
